package cn.com.panda.utils;

import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.Random;

/**
 * created by liujunlin on 2022/3/17 09:57
 */
public class PictureUtil {

    public static String modelPicName(String teamId,int picIndex,String fileExt,String ossPath){
        SimpleDateFormat dateFormat =new SimpleDateFormat("yyyyMMddHHmmss");
        String ossFileName = ossPath + "/p/t";
        ossFileName += teamId;
        ossFileName += "/" + dateFormat.format(new Date());
        ossFileName += teamId;
        ossFileName += "_" + index2String(picIndex);
        ossFileName += fileExt;
        return ossFileName;
    }

    public static String picName(String teamId,int picIndex,String fileExt){
        SimpleDateFormat dateFormat =new SimpleDateFormat("yyyyMMddHHmmss");
        String ossFileName = dateFormat.format(new Date()) + teamId + "_" + index2String(picIndex) + fileExt;
        return ossFileName;
    }

    private static String index2String(int index){
        if(index < 10)
            return "00"+index;
        else if(index < 100)
            return "0" + index;
        else
            return "" + index;
    }
}
